<?php $this->_extends('_layouts/default_layout'); ?>
 
<?php $this->_block('contents'); ?>
 
<script type="text/javascript" src="<?php echo $_BASE_DIR; ?>js/jquery.js"></script> 
<script type="text/javascript" src="<?php echo $_BASE_DIR; ?>js/ajaxfileupload.js"></script> 

<script type="text/javascript" charset="UTF-8">
	function ajaxFileUpload()
	{
		$("#loading")
		.ajaxStart(function(){
			$(this).show();
		})
		.ajaxComplete(function(){
			$(this).hide();
		});

		$.ajaxFileUpload
		(
			{
				//url:"<?php echo $_BASE_DIR; ?>js/uploadify/doajaxfileupload.php",
				url:"<?php echo url('column/uploadedimage', array('channel_id' => $col->id())); ?>",
				secureuri:false,
				fileElementId:'fileToUpload',
				dataType: 'json',
				success: function (data, status)
				{
					if(typeof(data.error) != 'undefined')
					{
						alert("###1###上传失败");
					}
					else
					{
						if(typeof(data.success) != 'undefined')
						{
						   alert("###4###上传成功");
						}
						else
						{
							alert("###31###上传失败");
						}

					}
				},
				error: function (data, status, e)
				{
					alert("###2###上传失败"+e);
				}
			}
		)
		
		return false;

	}

</script>

<h3>栏目编辑</h3>
<a href="<?php echo url('channel/index'); ?>">栏目管理</a>
<form id="form_usersetting" name="form_usersetting" action="<?php echo url('channel/edit'); ?>" method="post" enctype="application/x-www-form-urlencoded" qform_group_id="" 
        onsubmit="
		if (this.channel_title.value == '') { 
		alert('请输入栏目标题'); 
		return false; }
		else { 
			if (this.channel_desc.value == '') 
			{ 
				alert('请输入栏目描述'); 
				return false; 
			}
			else if (this.channel_seqence.value == '') 
			{ 
				alert('请输入栏目序号'); 
				return false; 
			}
			return true; 
		}"
>

  <fieldset>
    

  <p id="channel_name" >
    <label for="channel_title">栏目标题&nbsp;</label>
     <label><span class="error" name="warn_name" style="display:none" id="10014">请输入栏目标题</span></label>
    <input type="text"  id="10013" name="channel_title" onBlur="CheckIsNull(10013, 10014)" value="<?php echo $col->channel_name ?>" class="textbox_short" />
  </p>


  <p id="channel_desc" >
    <label for="channel_desc">栏目描述&nbsp;</label>
    
    <label><span class="error" name="warn_phone" style="display:none" id="10016">请输入栏目描述</span></label>
    
    <textarea type="num"  id="10015" name="channel_desc" onBlur="CheckIsNull(10015, 10016)" class="textbox" rows="10"><?php echo $col->channel_desc ?></textarea>
  </p>

  <p id="channel_seqence" >
    <label for="channel_seqence">栏目序号</label>
    
    <label><span class="error" style="display:none" id="10017">请输入栏目序号</span></label>
    
    <input type="text"  id="10018" name="channel_seqence"  value="<?php echo $col->channel_sequence ?>" onBlur="CheckIsNull(10018, 10017)" class="textbox_short" />
  </p>
  <input type="hidden" name="channel_id" id="channel_id" value="<?php echo $col->id() ?>" />
   <p id="channel_hide_or_not" >        
	 <label><input type="checkbox" name="channel_hide_or_not"  id="checkboxid" value="<?php echo $col->channel_status ?>" /><span>栏目隐藏否</span> </label>
   </p>
	<!--------------
  <p id="channel_seqence" >
    <label for="channel_seqence">栏目图片</label>
	 <label><input type="file" id="fileToUpload" name="fileToUpload" size="35" class="input"> 
		<button class="button" id="upload_button" onclick="return ajaxFileUpload();">上传</button><span><img id="loading" src="<?php echo $_BASE_DIR; ?>img/loading.gif" style="display:none;"></span>
		</label>
   </p>
   -------------->

   <p>
   <input type="submit" name="btn_submit" value="发送" class="btn" />      
   </p>

  </fieldset>
<script>
	function   LTrim(str)           //   左空格 
	{   
			var   i=0;  
			for(i=0;i <str.length;i++)   
			{   
			if(str.charAt(i)!= "   "&&str.charAt(i)!= "   ")break;
			}   
			str=str.substring(i,str.length);   
			return   str;   
	}   
	function   Trim(str)     //   两边空格 
	{   
			return   LTrim(str);   
	}  

    function CheckIsNull(check_id, des_id)
	{
        var name = document.getElementById(check_id);
		if("" == name.value || Trim(name.value)== " ")
		{				
			var objSrc = document.getElementById(des_id);
			objSrc.style.display = "";
		} 
		else
		{
			var objSrc = document.getElementById(des_id);
			objSrc.style.display = "none";
		}
	}
</script>

</form><?php $this->_endblock(); ?>